/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.example.test.core.mapper.master;

import com.example.test.core.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MasterUserMapper {

    /**
     * 根据登录名称查询用户
     *
     * @param loginName
     * @return
     */
    @Select("SELECT name as name FROM `sys_user` WHERE login_name=#{loginName}")
    public List<User> getName(@Param("loginName") String loginName);

    @Update("update `sys_user` set  `name`=#{name} where del_flag='0' and `no`=#{no}")
    public int updateUser(@Param("name") String name, @Param("no") String no);

    @Select("SELECT concat('A_',no) FROM `sys_user` where del_flag='0' and level_type is null and login_name is not null and login_name !='' and login_name!='admin' ORDER BY grade asc LIMIT 1500")
    public List<String> queryUsers();

    @Select("SELECT count(*) from sys_user u,sys_office o where u.office_id=o.id and u.level_type is null and u.del_flag='0' and u.no=#{no}")
    public int queryCountByNo(@Param("no") String no);

    @Select("SELECT company_name from sys_user u where u.level_type is null and u.del_flag='0' and u.user_center_id=#{id}")
    public String queryCompanyName(@Param("id") String id);
}